package com.itheima.info.manger.system.service;

import com.itheima.info.manger.system.dao.TeacherDao;
import com.itheima.info.manger.system.domain.Teacher;

public class TeacherService {
  private  TeacherDao teacherDao = new TeacherDao();
    //添加老师
    //参数
    //返回值
    public boolean addTeacher(Teacher teacher){

        boolean b = teacherDao.addTeacher(teacher);
        return b;
    }

    //判断老师的工号是否存在的方法
    //参数 录入的工号
    //返回值 存在 不存在
    public boolean isExist(String sid){
        //调用dao 获取所有老师
        Teacher[] teachers = teacherDao.findAllTeachers();
        //遍历所有老师
        for (int i = 0; i < teachers.length; i++) {
            //teachers[i]
            Teacher teacher = teachers[i];
            //判断工号是否相同 相同 返回 true
            if(teacher!=null&&teacher.getSid().equals(sid)){
                return true;
            }
        }
        //不同返回 false
        return false;

    }
}
